/*
 * TcpServer.h
 *
 *  Created on: Nov 9, 2012
 *      Author: root
 */

#ifndef zeus_ACCEPTOR_H_
#define zeus_ACCEPTOR_H_

#include "SocketsOps.h"

#include "Error.h"
#include "TcpSocket.h"
#include "SocketService.h"

namespace zeus
{

class Acceptor: private NonCopyAble
{
public:

	typedef std::function<void (const Error & err)> AcceptHandler;

private:

	SocketService _service;

	int32 _listen_fd;

	struct sockaddr_in _addr;

public:
	Acceptor(IoService & io_service);
	virtual ~Acceptor();

public:

	void listen(uint16 port);

	void accept(TcpSocket & peer,const AcceptHandler & complete_handler);
};

} /* namespace zeus */
#endif /* zeus_ACCEPTOR_H_ */
